﻿using System;

/*
 * Write a program to check if in a given expression the brackets are put correctly.
 * Example of correct expression: ((a+b)/5-d).
 * Example of incorrect expression: )(a+b)).
 */

namespace BracketsCheck
{
    class BracketsCheck
    {
        static bool CheckBrackets(string expression)
        {
            int brackets = 0;
            for (int index = 0, length = expression.Length; index < length && brackets >= 0; index++)
            {
                if (expression[index] == '(')
                {
                    brackets++;
                }
                else if (expression[index] == ')')
                {
                    brackets--;
                }
            }
            return brackets == 0;
        }
        static void Main()
        {
            Console.WriteLine(CheckBrackets("((a + b) * (2 - 3)) / 2"));
        }
    }
}
